package com.pactera.asmp.server.common.exception;

import com.pactera.asmp.server.common.constants.ResultCode;

import java.text.MessageFormat;

/**
 * @ProjectName: asmpserver
 * @Package: com.pactera.asmp.server.common.exception
 * @ClassName: CustomException
 * @Author: lvzhiqiang
 * @Description:
 * @Date: 2019/8/27 15:33
 * @Version: 1.0
 */
public class CustomException extends RuntimeException {

    final ResultCode resultCode;

    public CustomException(ResultCode resultCode){
        super(resultCode.message());
        this.resultCode = resultCode;
    }

    public ResultCode getResultCode(){
        return resultCode;
    }

    public CustomException(ResultCode resultCode, Object... args){
        super(resultCode.message());
        String message = MessageFormat.format(resultCode.message(), args);
        resultCode.setMessage(message);
        this.resultCode = resultCode;
    }

}
